package com.tyk.bookstore.back.product.model.query;

import com.tyk.bookstore.back.product.model.constant.BookValidateConstant;
import com.tyk.bookstore.back.product.model.enume.BookState;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description 书籍
 */
@Data
@Schema(name = "BookAddQuery", description = "书籍")
public class BookAddQuery implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "书名")
    @NotBlank
    @Size(min = BookValidateConstant.NAME_MIN_LENGTH, max = BookValidateConstant.NAME_MAX_LENGTH)
    @Pattern(regexp = BookValidateConstant.NAME_REGEXP)
    private String name;

    @Schema(description = "价格")
    @NotNull
    private BigDecimal price;

    @Schema(description = "封面路径")
    @NotBlank
    @Size(min = BookValidateConstant.COVER_MIN_LENGTH, max = BookValidateConstant.COVER_MAX_LENGTH)
    @Pattern(regexp = BookValidateConstant.COVER_REGEXP)
    private String cover;

    @Schema(description = "标题")
    @NotBlank
    @Size(min = BookValidateConstant.TITLE_MIN_LENGTH, max = BookValidateConstant.TITLE_MAX_LENGTH)
    @Pattern(regexp = BookValidateConstant.TITLE_REGEXP)
    private String title;

    @Schema(description = "书籍简介")
    @NotBlank
    @Size(min = BookValidateConstant.SUMMARY_MIN_LENGTH, max = BookValidateConstant.SUMMARY_MAX_LENGTH)
    @Pattern(regexp = BookValidateConstant.SUMMARY_REGEXP)
    private String summary;

    @Schema(description = "作者ID")
    @NotNull
    @Min(value = 1)
    private Long authorId;

    @Schema(description = "出版社ID")
    @NotNull
    @Min(value = 1)
    private Long publisherId;

    @Schema(description = "出版时间")
    @NotNull
    private LocalDateTime publishTime;

    @Schema(description = "ISBN")
    @NotBlank
    @Size(min = BookValidateConstant.ISBN_MIN_LENGTH, max = BookValidateConstant.ISBN_MAX_LENGTH)
    @Pattern(regexp = BookValidateConstant.ISBN_REGEXP)
    private String isbn;

    @Schema(description = "分类ID")
    @NotNull
    @Min(value = 1)
    private Long clazzId;

    @Schema(description = "字数[单位：万字]")
    @NotNull
    @DecimalMin("0")
    private BigDecimal wordNum;

    @Schema(description = "重量（单位：克）")
    // @NotNull
    @Min(value = 0)
    private Long weight;

    @Schema(description = "规格")
    @NotNull
    @Min(value = 0)
    private Integer format;

    @Schema(description = "状态[0下架，1上架]")
    @NotNull
    private BookState state;

    @Schema(description = "定时上架")
    private Boolean timedRelease;

    @Schema(description = "上架时间")
    @Future
    private LocalDateTime releaseTime;

    @Schema(description = "展示图片列表")
    @NotEmpty
    List<String> imgList;
}
